package com.extension.company.view.my;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.extension.company.admin.R;
import com.extension.company.common.widget.RealShapeImageView;

/**
 * 作者:zwk
 * 联系方式：497981239@qq.com
 * 时间：on 2019/7/3 10:57
 * 功能：横向时间轴的adapter
 */
public class TimeLineAdapter extends RecyclerView.Adapter<TimeLineAdapter.TimeHolder> {

	private Context context;

	public TimeLineAdapter(Context context) {
		this.context = context;
	}

	@NonNull
	@Override
	public TimeHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
		View view = LayoutInflater.from(context).inflate(R.layout.time_line_item, viewGroup, false);
		return new TimeHolder(view);
	}

	@Override
	public void onBindViewHolder(@NonNull TimeHolder timeHolder, int position) {

		if (position == 0) {
			timeHolder.lineleft.setVisibility(View.INVISIBLE);
		}
		if (position == 2) {
			timeHolder.circleImage.setImageResource(R.drawable.time_circle_success);  // 失败使用 time_line_faile
			timeHolder.lineRight.setVisibility(View.INVISIBLE);
		}

	}


	@Override
	public int getItemCount() {
		return 3;
	}

	class TimeHolder extends RecyclerView.ViewHolder {
		RealShapeImageView circleImage;

		View lineleft, lineRight;

		public TimeHolder(@NonNull View itemView) {
			super(itemView);
			circleImage = itemView.findViewById(R.id.time_circle);
			lineleft = itemView.findViewById(R.id.time_line_left);
			lineRight = itemView.findViewById(R.id.time_line_right);
		}
	}
}
